﻿using UnityEngine;
using System.Collections;

public class CameraFollow : MonoBehaviour {

    public GameObject player;
    private PlayerBehaviour playerScript;

    private bool onOrthographicFollow = false;
    private int deltaDistance = 0;

	// Use this for initialization
	void Start () {
        transform.position = new Vector3(player.transform.position.x + deltaDistance, transform.position.y, transform.position.z);
        Screen.SetResolution(1920, 1200, true);
        orthographicFollow();
        playerScript = player.GetComponent<PlayerBehaviour>();
	}
	
	// Update is called once per frame
    void FixedUpdate()
    {

        if (onOrthographicFollow)
        {
            //if (transform.position.x - player.transform.position.x < deltaDistance)
            transform.position = new Vector3(player.transform.position.x + deltaDistance, transform.position.y, transform.position.z);
        }
        else
        {
            transform.position = new Vector3(player.transform.position.x, transform.position.y, transform.position.z);
        }
	}


    public void orthographicFollow()
    {
        onOrthographicFollow = true;
        if (!Camera.main.orthographic)
        {
            Camera.main.orthographic = true;
        }
    }
}
